namespace CrossThreadUpdateUI
{
    using System;
    using System.Runtime.CompilerServices;
    using System.Windows.Forms;

    public static class Label
    {
        public static void AsyncUpdate(this System.Windows.Forms.Label ctrl, LabelAttrib attrib, object value)
        {
            ctrl.Invoke(new EventHandler((obj, ergs) =>
            {
                switch (attrib)
                {
                    case LabelAttrib.Text:
                        ctrl.Text = value.ToString();
                        return;

                    case LabelAttrib.Enabled:
                        ctrl.Enabled = (bool)value;
                        return;
                }
            }));
        }
    }
}

